<template>
  <div class="edit-dialog">
    <el-dialog
      title="合规审查"
      :visible.sync="complianceShow"
      width="628px"
      :before-close="handleClose"
      :close-on-click-modal="false"
      custom-class="dialog-box"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="118px"
        class="demo-ruleForm"
      >
        <!-- 合规审查 -->
        <el-form-item label="审核结果" prop="approvalStatus">
          <el-radio-group v-model="ruleForm.approvalStatus">
            <el-radio :label="35">通过</el-radio>
            <el-radio :label="36">驳回</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核意见" prop="approvalOpinion">
          <el-input
            type="textarea"
            v-model="ruleForm.approvalOpinion"
            :rows="3"
            maxlength="100"
            show-word-limit
          ></el-input>
        </el-form-item>
        <div class="select-template">
          <el-dropdown trigger="click" @command="handleCommand" placement="top">
            <span class="el-dropdown-link">
              选择模版<i class="icon-arrow-down el-icon-folder-remove"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                icon="el-icon-circle-check"
                v-for="dict in selectDemoList"
                :key="dict.dictValue"
                :command="dict.dictValue"
                >{{ dict.dictLabel }}</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getApprovalAdd } from "@/api/manage/manage";
export default {
  name: "complianceDialog",
  props: {
    complianceShow: {
      type: Boolean,
      default: "",
    },
    type: {
      type: String,
      default: "",
    },
    proid: {
      type: String,
      default: "",
    },
  },
  inject: ["reload"],
  data() {
    return {
      rules: {
        approvalStatus: [
          { required: true, message: "请选择结果", trigger: "change" },
        ],
      },
      ruleForm: {
        approvalStatus: "",
        approvalOpinion: "",
      },
      // 选择模板数据字典
      selectDemoList: [
        { dictValue: "方案描述不充分1", dictLabel: "方案描述不充分1" },
        { dictValue: "方案描述不充分2", dictLabel: "方案描述不充分2" },
        { dictValue: "方案描述不充分3", dictLabel: "方案描述不充分3" },
      ],
    };
  },
  methods: {
    /** 取消按钮 */
    handleClose() {
      this.$refs.ruleForm.resetFields();
      this.$emit("changeShowDialog", "false"); //调用父组件的自定义事件，并传值
    },
    /** 确定按钮 */
    submitForm() {
      this.ruleForm.projectId = this.proid;
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          getApprovalAdd(this.ruleForm).then((res) => {
            this.$refs.ruleForm.resetFields();
            this.$emit("changeShowDialog", "false");
            this.reload();
          });
        }
      });
    },
    // 选择模板内容
    handleCommand(command) {
      // console.log(9999,command);
      this.ruleForm.approvalOpinion = command;
    },
  },
};
</script>

<style lang="scss">
.edit-dialog {
  // 下载模板样式修改
  .select-template {
    .el-dropdown-link {
      color: #3171ee;
    }
    .icon-arrow-down {
      margin-left: 10px;
      color: #3171ee;
    }
    // width: 100%;
    display: flex;
    align-items: center;
    justify-content: right;
    font-size: 14px;
    font-family: PingFang SC, PingFang SC-Regular;
    font-weight: 400;
    text-align: LEFT;
    color: #3171ee;
    margin-left: 30%;
    margin-bottom: 20px;
    cursor: pointer;
    img {
      margin-left: 10px;
    }
  }
}
</style>
